#pragma once

#include <array>

#include "helpers.hpp"

namespace DSP {
	struct FirmwareInfo {
		using Hash = std::array<u8, 32>;

		Hash hash;  // Firmware hash (SHA-256)
		u32 size;   // Firmware size in bytes

		bool supportsAAC;   // Does this firmware support AAC decoding?
		const char* notes;  // Miscellaneous notes about the firmware

		explicit constexpr FirmwareInfo(const Hash& hash, u32 size, bool supportsAAC, const char* notes)
			: hash(hash), size(size), supportsAAC(supportsAAC), notes(notes) {}
	};

	static constexpr std::array<FirmwareInfo, 10> firmwareDB = {
		FirmwareInfo(
			{0x47, 0xD6, 0x6C, 0xD2, 0x13, 0x1, 0xFF, 0x62, 0xAD, 0x16, 0x98, 0x2,  0x46, 0x67, 0xF3, 0x9,
			 0xDA, 0x7,  0x20, 0x9E, 0xFB, 0xB, 0x6A, 0x81, 0x98, 0xFF, 0x9B, 0xE0, 0x51, 0x67, 0xC9, 0xA6},
			48480, false, "Spotted in some versions of Activity Log potentially other apps"
		),

		FirmwareInfo(
			{0xF5, 0xDA, 0x79, 0xE7, 0x24, 0x6C, 0x51, 0x9A, 0x28, 0x6C, 0x50, 0xC9, 0x9F, 0xA1, 0xE6, 0x4D,
			 0xA5, 0x72, 0x96, 0x5F, 0xEA, 0x14, 0x20, 0xA7, 0x70, 0x90, 0x57, 0x42, 0x34, 0x6E, 0x18, 0xD1},
			49674, false, "One of the most common firmwares. Found in NSMB2 and others"
		),

		FirmwareInfo(
			{0x94, 0x4B, 0x40, 0xB5, 0x46, 0x93, 0xF4, 0xB1, 0xD9, 0x52, 0xBE, 0x84, 0x87, 0xE9, 0xE9, 0x1F,
			 0x66, 0x7F, 0xC4, 0x89, 0xF8, 0x15, 0x79, 0xF,  0x3D, 0x3E, 0x89, 0x26, 0x5F, 0xE0, 0x89, 0xC4},
			49800, false, "One of the most common firmwares. Found in Majora's Mask and others"
		),

		FirmwareInfo(
			{0x8E, 0x21, 0x3F, 0x3E, 0x71, 0xD2, 0xE3, 0xE4, 0x5D, 0x11, 0x69, 0xBA, 0xC6, 0x46, 0x5A, 0x70,
			 0xEA, 0xBE, 0xB2, 0x2B, 0x30, 0x3F, 0x1F, 0xA6, 0xD7, 0x67, 0x93, 0x70, 0xFF, 0xAD, 0xF,  0x54},
			49756, false, "Fairly common firmware. Found in PSMD and others"
		),

		FirmwareInfo(
			{0xA2, 0x6C, 0x74, 0xD1, 0xEF, 0x7F, 0x4F, 0xA5, 0xFF, 0xFF, 0xFB, 0xEC, 0x75, 0x8A, 0x40, 0x8D,
			 0x8F, 0x22, 0x87, 0x72, 0x78, 0x1B, 0x81, 0x88, 0x86, 0x5F, 0x83, 0x4D, 0x1D, 0x90, 0x6B, 0xAA},
			48804, false, "Spotted in MK7"
		),

		FirmwareInfo(
			{0x75, 0x12, 0x70, 0xB2, 0x43, 0xB0, 0xCA, 0xFB, 0x51, 0x99, 0xF2, 0x98, 0x2,  0x2,  0xC9, 0xB4,
			 0xC7, 0x7A, 0x67, 0x5E, 0xF0, 0x43, 0x8F, 0xD5, 0xA8, 0x9E, 0x83, 0xAA, 0xB9, 0xA8, 0x7,  0x9B},
			48652, false, "One of the most common firmwares. Found in OoT, Pokemon Rumble Blast, and others"
		),

		FirmwareInfo(
			{0xF2, 0x96, 0xE2, 0xE5, 0xEC, 0x34, 0x9F, 0x6A, 0x6C, 0xF3, 0xE1, 0xC7, 0xC,  0xDD, 0x65, 0xC2,
			 0x2,  0x72, 0xB6, 0xE7, 0xFF, 0xE5, 0x57, 0x92, 0x69, 0x4E, 0x83, 0xAE, 0x24, 0xF1, 0x68, 0xBF},
			217976, true, "Most common AAC-enabled firmware. Found in Rhythm Heaven, Fire Emblem Fates/Echoes, Pokemon X/Y, and others"
		),

		FirmwareInfo(
			{0xF0, 0x6C, 0x1B, 0x59, 0x23, 0xE1, 0x71, 0x19, 0x5,  0x66, 0x59, 0xCB, 0x3D, 0x9B, 0xF0, 0x26,
			 0x62, 0x84, 0xE9, 0xA6, 0xC0, 0x8,  0x23, 0x99, 0xD7, 0x45, 0x8D, 0x7C, 0x52, 0xAE, 0x32, 0x1C},
			48708, false, "Spotted in Super Mario 3D Land"
		),

		FirmwareInfo(
			{0x7E, 0xA3, 0xC4, 0x4A, 0x1C, 0x57, 0x51, 0x4B, 0xEB, 0xBE, 0xBC, 0xE8, 0xA7, 0x99, 0x5F, 0x7F,
			 0x3A, 0x29, 0x1,  0x70, 0xEA, 0x3B, 0x6C, 0x14, 0x57, 0x49, 0xAD, 0x93, 0x58, 0x67, 0x2C, 0x97},
			49716, false, "Spotted in PMD: GTI"
		),

		FirmwareInfo(
			{0x96, 0xF3, 0x96, 0x28, 0x38, 0xEB, 0xE9, 0x2A, 0x9E, 0x99, 0xD0, 0xB0, 0x78, 0xAD, 0xE3, 0x67,
			 0x3B, 0x9B, 0x2F, 0x24, 0x3E, 0xBE, 0xC0, 0x47, 0x4D, 0x3E, 0x49, 0xA9, 0x2B, 0x65, 0x5B, 0x85},
			49772, false, "Spotted in Luigi's Mansion"
		),
	};
}  // namespace DSP